<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>服务信息显示</title>
<script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
var index = 0;
var diao = [{'type':'服务类型','id':'cstype'},{'type':'服务方式','id':'csstyle'},{'type':'服务效果','id':'cseffect'}];
	//字典加载  
	$(function() {
		dy();
		
		check();
	});
	//全选全不选
	function check(){
		$("input[name=qx]").click(function(){
			
			$("input[name=xz]").attr("checked",this.checked);
			
		});
	}
	//单选事件
	function dx(){
		$("input[name=xz]").click(function(){
			$("input[name=qx]").attr("checked",$("input[name=xz]").length==$("input[name=xz]:checked").length?true:false);			
		});
		
	}
	function dy(){
		if(index<diao.length){
			getDDL(diao[index].type,diao[index].id);
			setTimeout('dy()',100);
			index++;
		}
	}
	function getDDL(type,id){
		var date = new Date();
		$.getJSON("byTypeDDL.action",{"ddl.typeType":type,"date":date.getTime()},function(data){
			var o = "#"+id;
			var obj=$(o);
   		 for ( var i = 0; i < data.length; i++) {
   			 $(obj).append('<option value="'+data[i].id+'">'+data[i].value+'</option>');
			 }
		});
	}

	//显示信息
	$(function() {
		$.post('showCustService.action', {}, function(result) {
			var str = "";
			for ( var i = 0; i < result.length; i++) {
				str += '<tr><td><input type="checkbox" name="xz" onclick="dx();"/></td><td>'+ result[i].cid + '</td><td>'
						+ result[i].cother + '</td><td>' + result[i].ctime
						+ '</td><td>' + result[i].cuser + '</td><td>'
						+ result[i].style + '</td><td>' + result[i].type
						+ '</td><td>' + result[i].effect + '</td><td>'
						+ result[i].customer
						+ '</td><td><a href=getCustService.action?id='
						+ result[i].cid + '>修改</a> &nbsp;&nbsp; <a href="deleteCustService.action?id='
						+ result[i].cid
						+ '">删除</a></td></tr>';
			}
			$("#tb").html(str);
		}, 'json');
	});
	//高级查询
	function getKey(){
		var sty = $("#csstyle").val();
		var typ = $("#cstype").val();
		var eff = $("#cseffect").val();
		$.post('showKeyCustService.action', {"csstyle":sty,"cstype":typ,"cseffect":eff}, function(result) {

			var str = "";
			for ( var i = 0; i < result.length; i++) {
				str += '<tr><td><input type="checkbox" name="xz" id="xz" onclick="dx();"  value='+result[i].cid+' /></td><td>' + result[i].cid + '</td><td>'
						+ result[i].cother + '</td><td>' + result[i].ctime
						+ '</td><td>' + result[i].cuser + '</td><td>'
						+ result[i].style + '</td><td>' + result[i].type
						+ '</td><td>' + result[i].effect + '</td><td>'
						+ result[i].customer
						+ '</td><td><a href=getCustService.action?id='
						+ result[i].cid + '>修改</a> &nbsp;&nbsp; <a href="deleteCustService.action?id='
						+ result[i].cid
						+ '">删除</a></td></tr>';
			}
			$("#tb").html(str);
		}, 'json');
	}
	//execl导出
	function excel(){
		
		var path ='excelCustService.action';
		
		var xz = '';
		$('input[name="xz"]:checked').each(function(){
		
			xz += $(this).val()+',';
		});
		xz = xz.substring(0, xz.length - 1);
		if (xz.length == 0) {
			location.href = path;
		} else {
			location.href = path + '?xz=' + xz;
		}
	}
</script>
<link href="../css/table.css" rel="stylesheet" type="text/css">
</head>
<body>

	
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
		<thead>
        	<tr>
            	<td colspan="10" bgcolor="#FFFFFF"> 
                		服务类型：
		<select id="cstype" name="cstype">
			<option value="-1">        </option>
		</select>
		服务效果：
		<select id="cseffect" name="cseffect">
			<option value="-1">        </option>
		</select>
		服务方式：
		<select id="csstyle" name="csstyle">
			<option value="-1">        </option>
		</select>
		
		<input type="button" onclick="getKey();" value="  搜  索  ">
                </td>
          </tr>
	</div>

	
	<table width="100%"  border="0" cellpadding="0" cellspacing="0">
		<thead>
			<tr>
				<td><input type="checkbox" name="qx" id="all"/>全选</td>
				<td>编号</td>
				<td>内容</td>
				<td>创建时间</td>
				<td>操作员</td>
				<td>服务类型</td>
				<td>服务方式</td>
				<td>服务效果</td>
				<td>客户</td>
				<td>操作</td>
			</tr>
		</thead>
	
		<tbody id="tb">

		</tbody>
        
        <tfoot>
        	<tr>
            	<td colspan="10"><input type="button" value="  导  出  " onclick="excel();"></td>
            </tr>
        </tfoot>
	</table>
	<!-- 
	<tr>
		<td align="right"><a href="showCustService.action?curPage=${1}">首页</a>&nbsp;<a
			href="showCustService.action?curPage=${curPage-1}">上一页</a>&nbsp;<a
			href="showCustService.action?curPage=${curPage+1}">下一页</a>&nbsp;<a
			href="showCustService.action?curPage=${pageCount}">末页</a></td>
	</tr>
 	-->
    
</body>
</html>

